package com.sevenstudio.adu.gasing.element;

import org.andengine.entity.text.Text;
import org.andengine.opengl.font.StrokeFont;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.color.Color;

import com.sevenstudio.adu.gasing.define.iGameDefines;
import com.sevenstudio.adu.gasing.engine.Anchor;
import com.sevenstudio.adu.gasing.engine.GameEngine;
import com.sevenstudio.adu.gasing.engine.Utils;
import com.sevenstudio.adu.gasing.game.element.GameElementText;

public class AText 
{
	Text text;
	GameEngine theEngine;
	
	public AText(GameEngine mainActivity, GameElementText[] array_Element_Text, int index, AFont font)
	{
		theEngine = mainActivity;
		Load(index, array_Element_Text, font);
	}
	
	void Load(int index, GameElementText[] array_ElementText,AFont font) 
	{
		
		final VertexBufferObjectManager vertexBufferObjectManager = theEngine.getVertexBufferObjectManager();
		text = new Text(0, 0, font.theFont(), array_ElementText[index].getContent(), vertexBufferObjectManager);
		float x, y;
		x = Utils.GetAnchorX(text.getWidth(), array_ElementText[index].getAnchor()) + Utils.GetRatioWidth(array_ElementText[index].getX());
		y = Utils.GetAnchorY(text.getHeight(), array_ElementText[index].getAnchor()) + Utils.GetRatioHeight(array_ElementText[index].getY());
		text.setPosition(x, y);
	}
	
	public Text theText()
	{
		return text;
	}
	
	public void SetPos(float x, float y, Anchor anchor)
	{
		float _x, _y;
		_x = Utils.GetAnchorX(text.getWidth(), anchor) + Utils.GetRatioWidth(x);
		_y = Utils.GetAnchorY(text.getHeight(), anchor) + Utils.GetRatioHeight(y);
		
		SetPos(_x, _y);
	}
	
	public void SetPos(float x, float y)
	{
		text.setPosition(x, y);
		
	}
	
	public void setColor(Color color)
	{
		text.setColor(color);
	}
	
	public void setText(String str)
	{
		text.setText(str);
	}
	
	
}
